function init() {
  loadFriends();
}

function loadFriends() {
  var req = opensocial.newDataRequest();
  var params = {};
  params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] =
        [opensocial.Person.Field.GENDER];
  
  req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER,
		params), 'viewer');
		
  req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.VIEWER_FRIENDS,
		params),'viewerFriends'); 
  
  req.send(onLoadFriends);
}

function onLoadFriends(data) {
  var viewer = data.get('viewer').getData();
  var viewerFriends = data.get('viewerFriends').getData();
	alert(viewerFriends);
  html = new Array();
  html.push('<ul>');
    alert('test 1');
  viewerFriends.each(function(person) {
  alert('test 2');
  var AGE=person.getField(opensocial.Person.Field.GENDER);
  //var country = address.getField(opensocial.Address.Field.LOCALITY);
  alert(AGE);
    html.push('<li>' + ': '+ AGE + "</li>");
  });
  html.push('</ul>');
  document.getElementById('friends').innerHTML = html.join('');
}